package main

import (
	"fmt"
	"time"
)

//日期包
func main() {
	now := time.Now()
	fmt.Printf("%v 对应的结构体：%T\n", now, now)
	fmt.Println(now) //2023-01-11 10:53:53.6166443 +0800 CST m=+0.004066001

	fmt.Printf("年: %v \n", now.Year())
	fmt.Printf("月: %v \n", int(now.Month()))
	fmt.Printf("日: %v \n", now.Day())
	fmt.Printf("时: %v \n", now.Hour())
	fmt.Printf("分: %v \n", now.Minute())
	fmt.Printf("秒: %v \n", now.Second())
	fmt.Println("------------------------------------------")
	fmt.Printf("当前年月日: %d-%d-%d 时分秒: %d:%d:%d \n",
		now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second())
	dateStr := fmt.Sprintf("当前年月日: %d-%d-%d 时分秒: %d:%d:%d \n",
		now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second())
	fmt.Println(dateStr)

	dateStr = now.Format("2006/01/02 15/04/05")
	fmt.Println(dateStr)
	dateStr = now.Format("2006 15:04")
	fmt.Println(dateStr)

	str := "hello"
	fmt.Println(len(str))

	//内置函数new

	num := new(int)
	fmt.Println(num)
	fmt.Printf("num的类型:%T,num的值是:%v,num的地址:%v,num指针指向的值是:%v",num,num,&num,*num)
	//num的类型:*int,num的值是:0xc0001060c8,num的地址:0xc000114000,num指针指向的值是:0

}
